package org.androidpush.client;

import java.util.ArrayList;
import java.util.List;

import org.jivesoftware.smack.packet.IQ;

public class SetTagsIQ extends IQ {

	private String username;

	private List<String> taglList = new ArrayList<String>();

	public List<String> getTaglList() {
		return taglList;
	}

	public void setTaglList(List<String> taglList) {
		this.taglList = taglList;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Override
	public String getChildElementXML() {
		StringBuilder buf = new StringBuilder();
		buf.append("<").append("settags").append(" xmlns=\"")
				.append("androidpn:iq:settags").append("\">");
		if (username != null) {
			buf.append("<username>").append(username).append("</username>");
		}
		if(taglList.size()>0&&taglList!=null){
			buf.append("<tags>");
			boolean needSeperate = false;
			for(String tag:taglList){
				if(needSeperate){
					buf.append(",");
				}
				buf.append(tag);
				needSeperate = true;
			}
			buf.append("</tags>");
		}
		buf.append("</").append("settags").append("> ");
		return buf.toString();
	}

}
